package com.picture.controller;

import com.picture.pojo.dto.PictureStatusQueryDto;
import com.picture.pojo.dto.UserAssignDto;
import com.picture.pojo.entity.Picture;
import com.picture.pojo.entity.User;
import com.picture.pojo.entity.UserPicture;
import com.picture.pojo.vo.UserVo;
import com.picture.result.PageResult;
import com.picture.result.Result;
import com.picture.service.PictureService;
import com.picture.service.UserPictureService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("picture/userPicture")
@CrossOrigin
@Api(tags = "用户图片关系接口")
@Slf4j
public class UserPictureController {

    @Autowired
    private UserPictureService userPictureService;

    @ApiOperation("按照条件分页查询未标记的用户")
    @PostMapping("/list")
    public Result<PageResult> selectByStatus(@RequestBody PictureStatusQueryDto pictureStatusQueryDto){

        return userPictureService.listStatus(pictureStatusQueryDto);
    }

    @GetMapping("/user")
    @ApiOperation("查询所有用户")
    public Result<List<UserVo>> selectList(){
        return userPictureService.selectList();
    }

    @PostMapping("/assign")
    @ApiOperation(("分配图片"))
    public Result assignPicture(@RequestBody UserAssignDto userAssignDto){

        return userPictureService.assignPicture(userAssignDto);
    }


    @ApiOperation("查询用户图片")
    @PostMapping("/userPicture")
    public Result<PageResult> selectPictureByUserId(@RequestBody PictureStatusQueryDto pictureStatusQueryDto){
        return userPictureService.selectPictureByUserId(pictureStatusQueryDto);
    }

}
